package com.pand.model.station;

import com.pand.model.BaseObject;
import com.pand.model.company.Orgnization;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;

import javax.persistence.*;
import java.sql.Timestamp;

/**
 * 
 * @ClassName: ServiceStation
 * @Description: 网点
 *
 */
@Entity
@Table(name = "RES_SERVICE_STATION")
@SequenceGenerator(name = "SeqServiceStation", sequenceName = "SEQ_SERVICE_STATION", allocationSize = 1)
public class ServiceStation extends BaseObject {

	/**
	 * @Fields serialVersionUID :
	 */
	private static final long serialVersionUID = 1L;

	/**
	 * 主键
	 */
	private Long id;

	/**
	 * 站点编码
	 */
	private String stationCode;

	/**
	 * 站点名称
	 */
	private String stationName;

	/**
	 * 站点地址
	 */
	private String stationAddress;

	/**
	 * 区域id
	 */
	private Long areaId;

	/**
	 * 经度
	 */
	private Double latitude;

	/**
	 * 纬度
	 */
	private Double longtitude;

	/**
	 * 手机号
	 */
	private String phone;

	/**
	 * 是否有值守人员
	 */
	private Boolean isGuarding;

	/**
	 * 电桩数量
	 */
	private Integer pileNum;

	/**
	 * 可用电桩数量
	 */
	private Integer avlPileNum;

	/**
	 * 车辆数
	 */
	private Integer vehicleNum;

	/**
	 * 可租车辆数
	 */
	private Integer avlVehicleNum;

	/**
	 * 停车位数量
	 */
	private Integer parkingNum;

	/**
	 * 服务网点拼音首字母缩写
	 */
	private String pyjx;

	/**
	 * 是否为预设
	 */
	private boolean preset;

	/**
	 * 描述
	 */
	private String distance;

	/**
	 * 最低空闲车辆
	 */
	private Long minIdleNum = 0l;

	/**
	 * 所属组织
	 */
	private Orgnization orgnization;

	/**
	 * 网点位置类型 0：室内网点，1：室外网点
	 */
	private Integer stnType = 1;

	/**
	 * 网点还车距离，默认150米
	 */
	private Integer retDistance;

	/**
	 * 修改时间
	 */
	private Timestamp updateTime;

	/**
	 * 是否删除
	 */
	private Long isDelete = 0L;

	/**
	 * gps纬度
	 */
	private Double gps_latitude;

	/**
	 * gps经度
	 */
	private Double gps_longtitude;

    /**
     * geohash值，用于搜索附近站点
     **/
    private String geoHash;

    /**
    *useType 站点用途类型：0:普通;1：换电站;2:充电站
    */
    private Integer useType;

    @OneToOne(fetch = FetchType.EAGER, cascade = CascadeType.MERGE)
    @JoinColumn(name = "ORG_ID")
    @NotFound(action = NotFoundAction.IGNORE)
    public Orgnization getOrgnization() {
        return orgnization;
    }

	public void setOrgnization(Orgnization orgnization) {
		this.orgnization = orgnization;
	}

	@Column(name = "MIN_IDLE_NUM")
	public Long getMinIdleNum() {
		return minIdleNum;
	}

	public void setMinIdleNum(Long minIdleNum) {
		this.minIdleNum = minIdleNum;
	}

	@Transient
	public String getDistance() {
		return distance;
	}

	public void setDistance(String distance) {
		this.distance = distance;
	}

	@Id
	@GeneratedValue(generator = "SeqServiceStation")
	@Column(name = "ID")
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	@Column(name = "STATION_CODE")
	public String getStationCode() {
		return stationCode;
	}

	public void setStationCode(String stationCode) {
		this.stationCode = stationCode;
	}

	@Column(name = "STATION_NAME")
	public String getStationName() {
		return stationName;
	}

	public void setStationName(String stationName) {
		this.stationName = stationName;
	}

	@Column(name = "STATION_ADDRESS")
	public String getStationAddress() {
		return stationAddress;
	}

	public void setStationAddress(String stationAddress) {
		this.stationAddress = stationAddress;
	}

	@Column(name = "AREA_ID")
	public Long getAreaId() {
		return areaId;
	}

	public void setAreaId(Long areaId) {
		this.areaId = areaId;
	}

	@Column(name = "LATITUDE")
	public Double getLatitude() {
		return latitude;
	}

	public void setLatitude(Double latitude) {
		this.latitude = latitude;
	}

	@Column(name = "LONGTITUDE")
	public Double getLongtitude() {
		return longtitude;
	}

	public void setLongtitude(Double longtitude) {
		this.longtitude = longtitude;
	}

	@Column(name = "PHONE")
	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	@Column(name = "IS_GUARDING")
	public Boolean getIsGuarding() {
		return isGuarding;
	}

	public void setIsGuarding(Boolean isGuarding) {
		this.isGuarding = isGuarding;
	}

	@Column(name = "PILE_NUM")
	public Integer getPileNum() {
		return pileNum;
	}

	public void setPileNum(Integer pileNum) {
		this.pileNum = pileNum;
	}

	@Column(name = "AVL_PILE_NUM")
	public Integer getAvlPileNum() {
		return avlPileNum;
	}

	public void setAvlPileNum(Integer avlPileNum) {
		this.avlPileNum = avlPileNum;
	}

	@Column(name = "VEHICLE_NUM")
	public Integer getVehicleNum() {
		return vehicleNum;
	}

	public void setVehicleNum(Integer vehicleNum) {
		this.vehicleNum = vehicleNum;
	}

	@Column(name = "AVL_VEHICLE_NUM")
	public Integer getAvlVehicleNum() {
		return avlVehicleNum;
	}

	public void setAvlVehicleNum(Integer avlVehicleNum) {
		this.avlVehicleNum = avlVehicleNum;
	}

	@Column(name = "PARKING_NUM")
	public Integer getParkingNum() {
		return parkingNum;
	}

	public void setParkingNum(Integer parkingNum) {
		this.parkingNum = parkingNum;
	}

	@Column(name = "STATION_PYJX")
	public String getPyjx() {
		return pyjx;
	}

	public void setPyjx(String pyjx) {
		this.pyjx = pyjx;
	}

	@Column(name = "ISPRESET")
	public boolean getPreset() {
		return preset;
	}

	public void setPreset(boolean preset) {
		this.preset = preset;
	}

	@Column(name = "STN_TYPE")
	public Integer getStnType() {
		if (stnType != null)
			return stnType;
		else
			return 1;// 0：室内网点；1：室外网点
	}

	public void setStnType(Integer stnType) {
		if (stnType == null)
			stnType = 1;// 0：室内网点；1：室外网点
		this.stnType = stnType;
	}

	@Column(name = "RET_DISTANCE")
	public Integer getRetDistance() {
		return retDistance;
	}

	public void setRetDistance(Integer retDistance) {
		this.retDistance = retDistance;
	}

	@Column(name = "UPDATE_TIME")
	public Timestamp getUpdateTime() {
		return updateTime;
	}

	public void setUpdateTime(Timestamp updateTime) {
		this.updateTime = updateTime;
	}

	@Column(name = "IS_DELETE")
	public Long getIsDelete() {
		if (isDelete != null)
			return isDelete;
		else
			return 0L;// 0:不删除；1：删除
	}

	public void setIsDelete(Long isDelete) {
		if (isDelete == null)
			isDelete = 0L;// 0:不删除；1：删除
		this.isDelete = isDelete;
	}

	@Column(name = "gps_latitude")
	public Double getGps_latitude() {
		return gps_latitude;
	}

	public void setGps_latitude(Double gps_latitude) {
		this.gps_latitude = gps_latitude;
	}

	@Column(name = "gps_longtitude")
	public Double getGps_longtitude() {
		return gps_longtitude;
	}

	public void setGps_longtitude(Double gps_longtitude) {
		this.gps_longtitude = gps_longtitude;
	}

    @Column(name = "GEO_HASH")
    public String getGeoHash() {
        return geoHash;
    }

    public void setGeoHash(String geoHash) {
        this.geoHash = geoHash;
    }

    @Column(name = "USE_TYPE")
    public Integer getUseType() {
        return useType;
    }

    public void setUseType(Integer useType) {
        this.useType = useType;
    }
}
